package com.xiaoma.tpo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiaoma.tpo.dao.ChChapterDao;
import com.xiaoma.tpo.dao.ChSentenceDao;
import com.xiaoma.tpo.dao.ChWordDao;
import com.xiaoma.tpo.dao.ChTpoDao;
import com.xiaoma.tpo.domain.ChChapter;
import com.xiaoma.tpo.domain.ChSentence;
import com.xiaoma.tpo.domain.ChWord;
import com.xiaoma.tpo.domain.ChTpo;

@Service
public class ChapterService {
    
    @Autowired
    private ChChapterDao chapterDao;
    
    @Autowired
    private ChWordDao chapterWordDao;
    
    @Autowired
    private ChSentenceDao chapterSentenceDao;
    
    @Autowired
    private ChTpoDao tpoDao;

    public List<ChChapter> findByTpoId(int tpoId) {
        return chapterDao.findByTpoId(tpoId);
    }
    
    public List<ChSentence> findSentencesByChapterId(int chChapterId) {
        ChSentence entity = new ChSentence();
        entity.setChChapterId(chChapterId);
        return chapterSentenceDao.findByColumns(entity);
    }
    
    public List<ChWord> findWordsByChapterId(int chChapterId) {
        ChWord entity = new ChWord();
        entity.setChChapterId(chChapterId);
        return chapterWordDao.findByColumns(entity);
    }
    
    public List<ChTpo> findAllTpos() {
        return tpoDao.findAll();
    }
}
